﻿<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <title>萤火商城-商业版</title>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <meta name="renderer" content="webkit"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="icon" type="image/png" href="assets/common/i/favicon.ico"/>
    <meta name="apple-mobile-web-app-title" content="萤火商城-商业版"/>
    <link rel="stylesheet" href="Css/amazeui.min.css"/>
    <link rel="stylesheet" href="Css/app.css"/>
    <link rel="stylesheet" href="Css/font_783249_3hfdb7m5w0j.css">
    <script src="Scripts/jquery.min.js"></script>
    <script src="Scripts/api.js"></script>
    <script src="Scripts/func.js"></script>
    <script src="Scripts/font_783249_e5yrsf08rap.js"></script>
    <script>
        BASE_URL = 'https://demo.yiovo.com/';
        STORE_URL = 'index.php?s=/store';
    </script>
</head>

<body data-type="">
<div class="am-g tpl-g">
    <!-- 内容区域 start -->
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title am-cf">出售中的商品</div>
                </div>
                <div class="widget-body am-fr">
                    <!-- 工具栏 -->
                    <div class="page_toolbar am-margin-bottom-xs am-cf">
                        <form class="toolbar-form" action="">
                            <input type="hidden" name="s" value="/store/goods/index">
                            <div class="am-u-sm-12 am-u-md-3">
                                <div class="am-form-group">
                                    <div class="am-btn-group am-btn-group-xs">
                                        <a class="am-btn am-btn-default am-btn-success"
                                           href="index.php?s=/store/goods/add">
                                            <span class="am-icon-plus"></span> 新增
                                        </a>
                                    </div>
                                </div>
                            </div>
                            <div class="am-u-sm-12 am-u-md-9">
                                <div class="am fr">

                                    <div class="am-form-group am-fl">
                                        <select id="parentId" data-am-selected="{btnSize: 'sm', placeholder: '商品分类'}">
                                            <option value=""></option>
                                        </select>
                                    </div>
                                    <div class="am-form-group am-fl">
                                        <select name="goods_status"
                                                data-am-selected="{btnSize: 'sm', placeholder: '商品状态'}">
                                            <option value=""></option>
                                            <option value="10"
                                            >上架
                                            </option>
                                            <option value="20"
                                            >下架
                                            </option>
                                        </select>
                                    </div>
                                    <div class="am-form-group am-fl">
                                        <div class="am-input-group am-input-group-sm tpl-form-border-form">
                                            <input type="text" class="am-form-field" name="goods_name"
                                                   placeholder="请输入商品名称"
                                                   value="">
                                            <div class="am-input-group-btn">
                                                <button class="am-btn am-btn-default am-icon-search"
                                                        type="submit"></button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>

                    <div class="am-scrollable-horizontal am-u-sm-12">
                        <table width="100%" class="am-table am-table-compact am-table-striped
                         tpl-table-black am-text-nowrap">
                            <thead>
                            <tr>
                                <th>商品ID</th>
                                <th>商品图片</th>
                                <th>商品名称</th>
                                <th>商品分类</th>
                                <th>实际销量</th>
                                <th>商品排序</th>
                                <th>商品状态</th>
                                <th>添加时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody id="goodslist">
                            <tr>
                                <td class="am-text-middle">10011</td>
                                <td class="am-text-middle">
                                    <a href="http://static.yoshop.xany6.com/201808011200282d83e3838.jpg"
                                       title="点击查看大图" target="_blank">
                                        <img src="Picture/201808011200282d83e3838.jpg"
                                             width="50" height="50" alt="商品图片">
                                    </a>
                                </td>
                                <td class="am-text-middle">
                                    <p class="item-title">萤火付款演示</p>
                                </td>
                                <td class="am-text-middle">自营女包</td>
                                <td class="am-text-middle">25</td>
                                <td class="am-text-middle">50</td>
                                <td class="am-text-middle">
                                           <span class="j-state am-badge x-cur-p
                                           am-badge-success"
                                                 data-id="10011"
                                                 data-state="10">
                                               上架                                           </span>
                                </td>
                                <td class="am-text-middle">2018-07-29 11:27:38</td>
                                <td class="am-text-middle">
                                    <div class="tpl-table-black-operation">
                                        <a href="index.php?s=/store/goods/edit/goods_id/10011">
                                            <i class="am-icon-pencil"></i> 编辑
                                        </a>
                                        <a href="javascript:;" class="item-delete tpl-table-black-operation-del"
                                           data-id="10011">
                                            <i class="am-icon-trash"></i> 删除
                                        </a>
                                        <a class="tpl-table-black-operation-green"
                                           href="index.php?s=/store/goods/copy/goods_id/10011">
                                            一键复制
                                        </a>
                                    </div>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="am-u-lg-12 am-cf">
                        <div class="am-fr"></div>
                        <div class="am-fr pagination-total am-margin-right">
                            <div class="am-vertical-align-middle">总记录：11</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>

        var td_templet = '<td class="am-text-middle">{0}</td>'


        $(function () {
            var data = {}
            var refreshTable = function (goods) {
                console.log(goods);
                var tr = ""
                for (var i = 0; i < goods.total; i++) {
                    tr += "<tr>";
                    tr += StringFormat(td_templet, goods.rows[i].id);
                    tr += "</tr>";
                }
                $("#goodslist").append(tr);
            }
            var refreshCategory = function (parents) {
                var str = "";
                for (var i = 0; i < parents.length; i++) {
                    str += ('<option value="' + parents[i].id + '">' + parents[i].name + '</option>');
                    if (parents[i].nodes)
                        for (var j = 0; j < parents[i].nodes.length; j++)
                            str += ('<option value="' + parents[i].nodes[j].id + '">&nbsp;&nbsp;|-' + parents[i].nodes[j].name + '</option>');
                }
                console.log(str)
                $("#parentId").append(str);
            }
            getGoods(data, refreshTable);
            getLevel(refreshCategory)
            // 商品状态
            $('.j-state').click(function () {
                // 验证权限
                if (!"1") {
                    return false;
                }
                var data = $(this).data();
                layer.confirm('确定要' + (parseInt(data.state) === 10 ? '下架' : '上架') + '该商品吗？'
                    , {title: '友情提示'}
                    , function (index) {
                        $.post("index.php?s=/store/goods/state"
                            , {
                                goods_id: data.id,
                                state: Number(!(parseInt(data.state) === 10))
                            }
                            , function (result) {
                                result.code === 1 ? $.show_success(result.msg, result.url)
                                    : $.show_error(result.msg);
                            });
                        layer.close(index);
                    });

            });

            // 删除元素
            var url = "index.php?s=/store/goods/delete";
            $('.item-delete').delete('goods_id', url);

        });
    </script>


</div>
<!-- 内容区域 end -->

</div>
<script src="Scripts/layer.js"></script>
<script src="Scripts/jquery.form.min.js"></script>
<script src="Scripts/amazeui.min.js"></script>
<script src="Scripts/webuploader.html5only.js"></script>
<script src="Scripts/art-template.js"></script>
<script src="Scripts/app.js"></script>
<script src="Scripts/file.library.js"></script>
</body>

</html>
